package com.kugua.zfms.zookeeper;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.data.Stat;

/**
 * <p>TODO</p>
 * <p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期         修改人          修改内容
 * </PRE>
 *
 * @author cuiyh9
 * @version 1.0
 * @Date Created in 2018年11月30日 14:45
 * @since 1.0
 */
public class ZookeeperDemo {
    public static void main(String[] args) {

        RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
        CuratorFramework client = CuratorFrameworkFactory.newClient("zk.soa.d.ziroom.com:2181", retryPolicy);
        client.start();
        try {
//          client.create().withMode(CreateMode.EPHEMERAL).forPath("/zfms/1", "dd".getBytes("UTF-8"));
            client.create().creatingParentsIfNeeded().forPath("/cuiyh/cc");
          System.out.println("create success ");

        } catch (KeeperException.NodeExistsException ee) {
            ee.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        client.close();

    }
}
